/*
package com.ujiuye.controller;


import com.ujiuye.service.UserService;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;

@Controller
public class UserController {


    //页面加载
    @RequestMapping(value = "/getUserList.action")
    public ModelAndView getUserList() {
        List<User> userList = userService.getUserList();
        ModelAndView mav = new ModelAndView();
        mav.setViewName("userlist");
        mav.addObject("userlist", userList);
        return mav;
    }

    //文件导入然后后台和页面加载
    @RequestMapping("/excelImport.action")
    public String excelImport(@RequestParam MultipartFile excel) throws IOException {
        InputStream is = excel.getInputStream();
        XSSFWorkbook wb = new XSSFWorkbook(is);
        XSSFSheet sheet = wb.getSheetAt(0);
        int rows = sheet.getPhysicalNumberOfRows();
        //注意根据需求是从第n-1行开始，下标是从0开始的
        for (int i = 1; i < rows; i++) {
            XSSFRow row = sheet.getRow(i);
            XSSFCell cell = row.getCell(0);
            cell.setCellType(CellType.STRING);
            String id = cell.getStringCellValue();

            XSSFCell cellName = row.getCell(1);
            cellName.setCellType(CellType.STRING);
            String name = cellName.getStringCellValue();

            User user = new User();
            user.setId(Integer.parseInt(id));
            user.setName(name);

            userService.saveUser(user);
        }
        return "redirect:/getUserList.action";
    }

    //导出全部
    @RequestMapping("/excelExportAll")
    @ResponseBody
    public String excelExportAll() {
        List<User> userList = userService.getUserList();
        XSSFWorkbook wb = new XSSFWorkbook();
        XSSFSheet sheet = wb.createSheet();
        for (int i = 0; i < userList.size(); i++) {
            XSSFRow row = sheet.createRow(i);
            row.createCell(0).setCellValue(userList.get(i).getId());
            row.createCell(1).setCellValue(userList.get(i).getName());
        }
        try {
            FileOutputStream fos = new FileOutputStream("C:\\Users\\Saul.J.Wu\\Desktop\\a.xlsx");
            wb.write(fos);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return "ok";
    }
}
*/
